<#include "config.ftl">
<#include "common_function.ftl">

<#-- 页面统一基础模板 -->
<#macro page title=macro_config.default_title body="" head="" setReferUrl=false referUrlKey="">
<#if setReferUrl><#if referUrlKey?has_content>${action.setReferUrl(referUrlKey)}<#else>${action.setReferUrl()}</#if></#if>
<#if navi?has_content>
	<#if title==macro_config.default_title>
		<#local title = navi?last>
	</#if>
</#if>
<html>
<head>
	<title>${macro_config.common_title} - ${title?html}</title>
	<#list macro_config.css_path as css>
	<link href="${base}${css}" rel="stylesheet" type="text/css">
	</#list>
	<#list macro_config.js_path as js>
	<script language="javascript" src="${base}${js}"></script>
	</#list>
	<script type="text/javascript" src="${base}/js/swfobject.js"></script>
	<meta http-equiv="Content-type" content="text/html; charset=${macro_config.charset}">
	${head}
</head>
<#if req.servletPath?starts_with(macro_config.manage_path)>
<body ${body}>
<#nested>
</body>
<#else>
<body ${body}>
<#nested>
</body>
</#if>
</html>
</#macro>

<#-- 后台导航、说明、功能链接设置 -->
<#macro intro navi=[] tasks={}>
<div id="navi"><#list navi as item><@p.menuMark/> ${item} </#list></div>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="explain">
<tr>
	<td><#nested></td>
</tr>
</table>
<#if (tasks?size > 0)>
<div style="margin-top:5px">
<#assign keys = tasks?keys>
<#list keys as key><a href="${parseLink(tasks[key])}" class="navlink">${key}</a> </#list>
</div>
</#if>
</#macro>

<#-- 设置表格奇偶行样式 -->
<#macro trClass>
<#if lineNumber?exists>
<#assign lineNumber=lineNumber+1/>
<#else>
<#assign lineNumber=1/>
</#if>
class="style${lineNumber%2}"
</#macro>

<#-- 表单必填项标识 -->
<#macro mustMark><span class="notNull">*</span></#macro>

<#-- 导航项间隔标识 -->
<#macro menuMark><span style="font-family:Webdings;color:#FF3300;font-weight:normal;">4</span></#macro>

<#-- 统计图表横向柱状图 -->
<#macro chartColumn width height="8" color="#0066CC"><span style="background:${color};height:${height};width:${width}"></span></#macro>

<#-- 表格鼠标覆盖后换色 -->
<#macro trChangeColor>
 onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"
</#macro>

<#-- 处理分页参数 -->
<#function getPageUrl pageNum>
<#local pageUrl=base+fullUrlWithoutPageNum>
<#if pageUrl?ends_with("?")>
<#return pageUrl + "pageNum=" + pageNum>
<#else>
<#return pageUrl + "&pageNum=" + pageNum>
</#if>
</#function>

<#-- 分页信息 -->
<#macro paging pagingList>
<#local pageCount=pagingList.pageCount>
<#local rowCount=pagingList.rowCount>
<#local pageNum=pagingList.pageNum>
<#local pageSize=pagingList.pageSize>
<#if rowCount == 0>
	<#if useFlag?exists>
	<div style="border:1px solid #666;padding:2 5 2 5;background:#efefef;color:#333">没有相关记录</div>
	<#else>
	<#assign useFlag = 1>
	</#if>
<#else>
<table>
<tr>
	<td style="line-height:150%">
	共 ${rowCount} 条记录 ${pageCount} 页
	<#if (pageCount <= 11)>
		<#local startPage = 1>
		<#local endPage = pageCount>
	<#elseif (pageNum + 5 > pageCount)>
		<#local startPage = pageCount - 10>
		<#local endPage = pageCount>
	<#elseif (pageNum - 5 < 1)>
		<#local startPage = 1>
		<#local endPage = 11>
	<#else>
		<#local startPage = pageNum - 5>
		<#local endPage = pageNum + 5>
	</#if>
	<#if (pageCount > 1)><#if (pageNum != 1)><#if (pageCount > 11)><a class="page" href="${getPageUrl(1)}" style="font-family:Webdings" title="首页">9</a></#if><a class="page" href="${getPageUrl(pageNum-1)}" style="font-family:Webdings" title="上页">3</a><#else><#if (pageCount > 11)><span style="font-family:Webdings;color:#999">9</span></#if><span style="font-family:Webdings;color:#999">3</span></#if><#list startPage..endPage as x><#if x=pageNum><span class="selectedPage">${x}</span><#else><span class="noSelectedPage"><a class="page" href="${getPageUrl(x)}">${x}</a></span></#if></#list><#if (pageCount != pageNum)><a class="page" href="${getPageUrl(pageNum+1)}" style="font-family:Webdings" title="下页">4</a><#if (pageCount > 11)><a class="page" href="${getPageUrl(pageCount)}" style="font-family:Webdings" title="尾页">:</a></#if><#else><span style="font-family:Webdings;color:#999">4</span><#if (pageCount > 11)><span style="font-family:Webdings;color:#999">:</span></#if></#if></#if>
	</#if>
	</td>
</tr>
</table>
</#macro>

<#-- 日历控件 -->
<#--
	id : 目标input元素的id（注意，不是name属性，是id属性）
 -->
<#macro cal id format="%Y-%m-%d" text="选择日期">
<#if calcount?exists>
<#assign calcount=calcount+1>
<#else>
<#assign calcount=0>
${importCSS("/components/calendar/skins/aqua/theme.css")}
${importJS("/components/calendar/calendar.js")}
${importJS("/components/calendar/calendar-setup.js")}
${importJS("/components/calendar/lang/calendar-zh-utf8.js")}
</#if>
<img id="calImg${calcount}" src="${base}/components/calendar/skins/aqua/cal.gif" border="0" alt="${text}" style="cursor:pointer">
<script language="JavaScript">Calendar.setup({inputField:"${id}",ifFormat:"${format}",button:"calImg${calcount}"});</script>
</#macro>

<#-- HTML编辑控件 FCKEditor -->
<#macro editor id bar="Default" value="" browser=false upload=false width="80%" height="400px">
<#if editorcount?exists>
<#assign editorcount=editorcount+1>
<#else>
<#assign editorcount=0>
${importJS("/components/fckeditor/fckeditor.js")}
</#if>
<script type="text/javascript">
var oFCKeditor${editorcount} = new FCKeditor("${id}");
oFCKeditor${editorcount}.BasePath = "${base}/components/fckeditor/";
oFCKeditor${editorcount}.Width = "${width}";
oFCKeditor${editorcount}.Height = "${height}";
oFCKeditor${editorcount}.ToolbarSet = "${bar}" ;
<#if browser>
oFCKeditor${editorcount}.Config['LinkBrowser'] = true;
oFCKeditor${editorcount}.Config['ImageBrowser'] = true;
oFCKeditor${editorcount}.Config['FlashBrowser'] = true; 
</#if>
<#if upload>
oFCKeditor${editorcount}.Config['LinkUpload'] = true;
oFCKeditor${editorcount}.Config['ImageUpload'] = true;
oFCKeditor${editorcount}.Config['FlashUpload'] = true;
</#if>
oFCKeditor${editorcount}.Value = "${value?default('')?js_string}";
oFCKeditor${editorcount}.Create();
</script>
</#macro>

<#-- 树形控件 dtree -->
<#--
	两种使用方式：第一种传入nodes，自动生成树，第二种自己写树的内容，形如d.add(...)的形式，注意“d”要与id相同
 -->
<#macro dtree id nodes=[] batch=false useCookies=false target="_self">
<#if dtreecount?exists>
<#assign dtreecount=dtreecount+1>
<#else>
<#assign dtreecount=0>
${importCSS("/components/dtree/dtree.css")}
<script type="text/javascript">var dtreeIconBasePath = "${base}/components/dtree/";</script>
${importJS("/components/dtree/dtree.js")}
</#if>
<div class="dtree">
<#if batch><div align="center"><a href="javascript: ${id}.openAll();">打开</a> | <a href="javascript: ${id}.closeAll();">折叠</a></div></#if>
<script type="text/javascript">
${id} = new dTree('${id}');
${id}.config.target = "${target}";
${id}.config.useCookies = ${useCookies?string};
<#if nodes?has_content>
<#list nodes as node>
${id}.add(<#list node?values as val><#if val_index gt 0>,</#if>'${val?string}'</#list>);
</#list>
<#else>
<#nested>
</#if>
document.write(${id});
</script>
</div>
</#macro>

<#-- Ajax树形控件 xloadtree -->
<#macro xloadtree>
<#if xloadtreecount?exists>
<#assign xloadtreecount=xloadtreecount+1>
<#else>
<#assign xloadtreecount=0>
${importCSS("/components/xloadtree/xtree.css")}
<script type="text/javascript">var xloadtreeIconBasePath = "${base}/components/xloadtree/";</script>
${importJS("/components/xloadtree/xtree.js")}
${importJS("/components/xloadtree/xmlextras.js")}
${importJS("/components/xloadtree/xloadtree.js")}
</#if>
<script type="text/javascript">
<#nested>
</script>
</#macro>

<#-- 缓存页面执行结果-通过时间 -->
<#macro cacheByTime key time refresh=false>
<#if cacheByTimeCount?exists>
<#assign cacheByTimeCount=cacheByTimeCount+1>
<#else>
<#assign cacheByTimeCount=0>
<#assign oscache=JspTaglibs["/WEB-INF/oscache.tld"]>
</#if>
<@oscache.cache key=key time=time refresh=refresh>
<#nested>
</@oscache.cache>
</#macro>

<#-- 缓存页面执行结果-通过写文件 -->
<#macro cacheByFile path file parse=false>
<#attempt>
<#include "${@neo.core.Constants@CACHE_BASE_PATH}${path}/${file}" parse=parse>
<#recover>
<#assign _CACHE_CONTENT_>
<#nested>
</#assign>
${@neo.core.util.FileUtil@addFileCache(path,file,_CACHE_CONTENT_)}
${_CACHE_CONTENT_}
</#attempt>
</#macro>